package com.zxcl.controller;

import com.alibaba.fastjson2.JSON;
import com.zxcl.model.AliPayModel;
import com.zxcl.pay.PayService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;


@RestController
public class OrderController {

  /**
   * 给支付宝进行回调的接口
   * http://localhost:8888/callBack
   */
  @RequestMapping("pay")
  public Object pay(String outTradeNo){
//    String outTradeNo="ORDER_MALL_004";
    String subject="MALL商品的支付订单";
    String totalAmount="10";
    String notifyUrl="http://tjfrba.natappfree.cc/callBack";  //改一下等下
    AliPayModel aliModel=new AliPayModel(outTradeNo,subject,totalAmount,notifyUrl);
    Map<String, Object> map = PayService.pay(aliModel);
    Object code = map.get("code");
//    if(code.equals("200")){
//      String qrCode = map.get("qrCode").toString();
//      System.out.println(qrCode);
//    }else{
//      System.out.println("唤起支付失败");
//    }
    return map;
  }
}
